/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaServices;

import entities.Clinsdoeil;
import entities.MyBatisUtil;
import java.util.List;
import org.apache.ibatis.session.SqlSession;

/**
 *
 * @author michael
 */
public class ClindoeilManager {
    
    public static void insertClinsdoeil(Clinsdoeil user) {
	  SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession();
	  try{
	  sqlSession.insert("mapper.ClinsdoeilMapper.insertClinsdoeil", user);	  
	  sqlSession.commit();
	  }finally{
	   sqlSession.close();
	  }
	 }
	 
	 public static List<Clinsdoeil> getClinsdoeilByUserId(int userId) {
	  SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession();
	  try{
	  List<Clinsdoeil> userMapper = sqlSession.selectList("mapper.ClinsdoeilMapper.getById", userId);
	  return userMapper;
	  }finally{
	   sqlSession.close();
	  }
	 }
	                
	 public static List<Clinsdoeil> getAllUsers() {
	  SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession();
	  try{
	  List<Clinsdoeil> userMapper = sqlSession.selectList("mapper.ClinsdoeilMapper.getAll");
	  return userMapper;
	  }finally{
	   sqlSession.close();
	  }
	 }
	 
	 public static void updateClinsdoeil(Clinsdoeil user) {
	  SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession();
	  try{
	  sqlSession.update("mapper.ClinsdoeilMapper.updateClinsdoeil", user);	  
	  sqlSession.commit();
	  }finally{
	   sqlSession.close();
	  }
	   
	 }
	 
	 public static void deleteClinsdoeil(int userId) {
	  SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession();
	  try{
	  sqlSession.delete("mapper.ClinsdoeilMapper.deleteClinsdoeil", userId);	  
	  sqlSession.commit();
	  }finally{
	   sqlSession.close();
	  }
         }
                
    
}
